package com.qc.task;

import javax.annotation.Resource;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.qc.common.DateUtil;
import com.qc.entity.ActivityTimeEntity;
import com.qc.service.ActivityTimeService;

@Component
public class ActivityTask {

	@Resource(name="activityTimeService")
	private ActivityTimeService activityTimeService;
	
	//每周一 凌晨 零一分 执行 （1~7  = SUN，MON，TUE，WED，THU，FRI，SAT）
	@Scheduled(cron = "0 1 0 ? * SUN ") 
    public void saveActivity() {
		
		String zhouyi = DateUtil.monday();
		
		String zhouri = DateUtil.sunday2();
		
		ActivityTimeEntity activityTime = new ActivityTimeEntity();
		
		activityTime.setStartDate(zhouyi);
		activityTime.setEndDate(zhouri);
		
		activityTimeService.saveActivityTime(activityTime);
		
		System.out.println("saveActivity success");
		
	}
}
